package com.misoneism.fire.service
{
	import com.google.maps.interfaces.IClientGeocoder;
	import com.misoneism.fire.event.IncidentParserEvent;
	import com.misoneism.fire.model.CFAIncident;
	import com.misoneism.fire.model.IIncident;
	import com.misoneism.fire.model.IncidentSizeEnum;
	import com.misoneism.fire.model.IncidentStatusEnum;
	import com.misoneism.fire.model.IncidentTypeEnum;
	
	import org.as3commons.collections.framework.IIterator;
	import org.as3commons.collections.framework.IList;
	import org.flexunit.asserts.assertEquals;
	import org.flexunit.asserts.assertNotNull;
	import org.flexunit.async.Async;

	public class CFAIncidentParserTest
	{
		private static const GOOD_DATA: XML =
			<rss xmlns:datetime="http://exslt.org/dates-and-times" version="2.0">
				<channel>
					<title>Statewide Current Incident Summary</title>
					<link>http://www.cfa.vic.gov.au/incidents/incident_summary.htm?tm=18072011120000</link>
					<description>Current activity (over the previous 5 hours) is listed below.</description>
					<language>en-us</language>
					<pubDate>Mon, 18 Jul 2011 06:41:01 GMT</pubDate>
					<lastBuildDate></lastBuildDate>
					<docs>http://blogs.law.harvard.edu/tech/rss</docs>
					<generator>Whispir RSS Engine</generator>
					<managingEditor>no-reply@whispir.com</managingEditor>
					<webMaster>no-reply@whispir.com</webMaster>
					<ttl>5</ttl>
					<item>
						<title>BELMONT, BARRABOOL RD</title>
						<link>http://www.cfa.vic.gov.au/incidents/incident_summary.htm</link>
						<description>
						   &lt;b&gt;District/Region:&lt;/b&gt; REGION 07&lt;br&gt;
						   &lt;b&gt;Location:&lt;/b&gt; BELMONT&lt;br&gt;
						   &lt;b&gt;Name:&lt;/b&gt; BARRABOOL RD&lt;br&gt;
						   &lt;b&gt;Last Updated Date/Time:&lt;/b&gt; 18/07/11 04:34:00 PM&lt;br&gt;
						   &lt;b&gt;Type:&lt;/b&gt; STRUCTURE&lt;br&gt;
						   &lt;b&gt;Status:&lt;/b&gt; GOING&lt;br&gt;
						   &lt;b&gt;Size:&lt;/b&gt; SMALL&lt;br&gt;
						   &lt;b&gt;Appliances:&lt;/b&gt; 3&lt;br&gt;
						   &lt;b&gt;Start Date/Time:&lt;/b&gt; 18/07/11 04:34:00 PM&lt;br&gt;
						</description>
						<pubDate>Mon, 18 Jul 2011 06:34:00 GMT</pubDate>
						<guid>1321966</guid>
					</item>
				
					<item>
					<title>MAIDEN GULLY, </title>
					<link>http://www.cfa.vic.gov.au/incidents/incident_summary.htm</link>
					<description>
					   &lt;b&gt;District/Region:&lt;/b&gt; REGION 02&lt;br&gt;
					   &lt;b&gt;Location:&lt;/b&gt; MAIDEN GULLY&lt;br&gt;
					   &lt;b&gt;Name:&lt;/b&gt; &lt;br&gt;
					   &lt;b&gt;Last Updated Date/Time:&lt;/b&gt; 18/07/11 04:07:00 PM&lt;br&gt;
					   &lt;b&gt;Type:&lt;/b&gt; RESCUE&lt;br&gt;
					   &lt;b&gt;Status:&lt;/b&gt; CONTROLLED&lt;br&gt;
					   &lt;b&gt;Size:&lt;/b&gt; SPOT&lt;br&gt;
					   &lt;b&gt;Appliances:&lt;/b&gt; 0&lt;br&gt;
					   &lt;b&gt;Start Date/Time:&lt;/b&gt; 18/07/11 03:39:00 PM&lt;br&gt;
					</description>
					<pubDate>Mon, 18 Jul 2011 06:07:00 GMT</pubDate>
					<guid>1321965</guid>
				</item>
				
				<item>
					<title>WENDOUREE, RING RD</title>
					<link>http://www.cfa.vic.gov.au/incidents/incident_summary.htm</link>
					<description>
					   &lt;b&gt;District/Region:&lt;/b&gt; REGION 15&lt;br&gt;
					   &lt;b&gt;Location:&lt;/b&gt; WENDOUREE&lt;br&gt;
					   &lt;b&gt;Name:&lt;/b&gt; RING RD&lt;br&gt;
					   &lt;b&gt;Last Updated Date/Time:&lt;/b&gt; 18/07/11 03:33:00 PM&lt;br&gt;
					   &lt;b&gt;Type:&lt;/b&gt; WASHAWAY&lt;br&gt;
					   &lt;b&gt;Status:&lt;/b&gt; CONTAINED&lt;br&gt;
					   &lt;b&gt;Size:&lt;/b&gt; MEDIUM&lt;br&gt;
					   &lt;b&gt;Appliances:&lt;/b&gt; 0&lt;br&gt;
					   &lt;b&gt;Start Date/Time:&lt;/b&gt; 18/07/11 02:46:00 PM&lt;br&gt;
					</description>
					<pubDate>Mon, 18 Jul 2011 05:33:00 GMT</pubDate>
					<guid>1321962</guid>
				</item>
				
				<item>
					<title>LONG GULLY, BROWN ST</title>
					<link>http://www.cfa.vic.gov.au/incidents/incident_summary.htm</link>
					<description>
					   &lt;b&gt;District/Region:&lt;/b&gt; REGION 02&lt;br&gt;
					   &lt;b&gt;Location:&lt;/b&gt; LONG GULLY&lt;br&gt;
					   &lt;b&gt;Name:&lt;/b&gt; BROWN ST&lt;br&gt;
					   &lt;b&gt;Last Updated Date/Time:&lt;/b&gt; 18/07/11 03:30:00 PM&lt;br&gt;
					   &lt;b&gt;Type:&lt;/b&gt; STRUCTURE&lt;br&gt;
					   &lt;b&gt;Status:&lt;/b&gt; COMPLETED&lt;br&gt;
					   &lt;b&gt;Size:&lt;/b&gt; LARGE&lt;br&gt;
					   &lt;b&gt;Appliances:&lt;/b&gt; 0&lt;br&gt;
					   &lt;b&gt;Start Date/Time:&lt;/b&gt; 18/07/11 03:18:00 PM&lt;br&gt;
					</description>
					<pubDate>Mon, 18 Jul 2011 05:30:00 GMT</pubDate>
					<guid>1321964</guid>
				</item>
		
				<item>
					<title>BENDIGO, </title>
					<link>http://www.cfa.vic.gov.au/incidents/incident_summary.htm</link>
					<description>
					   &lt;b&gt;District/Region:&lt;/b&gt; REGION 02&lt;br&gt;
					   &lt;b&gt;Location:&lt;/b&gt; BENDIGO&lt;br&gt;
					   &lt;b&gt;Name:&lt;/b&gt; &lt;br&gt;
					   &lt;b&gt;Last Updated Date/Time:&lt;/b&gt; 18/07/11 03:04:00 PM&lt;br&gt;
					   &lt;b&gt;Type:&lt;/b&gt; FALSE ALARM&lt;br&gt;
					   &lt;b&gt;Status:&lt;/b&gt; SAFE&lt;br&gt;
					   &lt;b&gt;Size:&lt;/b&gt; SMALL&lt;br&gt;
					   &lt;b&gt;Appliances:&lt;/b&gt; 0&lt;br&gt;
					   &lt;b&gt;Start Date/Time:&lt;/b&gt; 18/07/11 02:56:00 PM&lt;br&gt;
					</description>
					<pubDate>Mon, 18 Jul 2011 05:04:00 GMT</pubDate>
					<guid>1321963</guid>
				</item>
				
				<item>
					<title>BEECHWORTH, BEECHWORTH-WANGARATTA RD</title>
					<link>http://www.cfa.vic.gov.au/incidents/incident_summary.htm</link>
					<description>
					   &lt;b&gt;District/Region:&lt;/b&gt; REGION 24&lt;br&gt;
					   &lt;b&gt;Location:&lt;/b&gt; BEECHWORTH&lt;br&gt;
					   &lt;b&gt;Name:&lt;/b&gt; BEECHWORTH-WANGARATTA RD&lt;br&gt;
					   &lt;b&gt;Last Updated Date/Time:&lt;/b&gt; 18/07/11 02:19:00 PM&lt;br&gt;
					   &lt;b&gt;Type:&lt;/b&gt; RESCUE&lt;br&gt;
					   &lt;b&gt;Status:&lt;/b&gt; SAFE&lt;br&gt;
					   &lt;b&gt;Size:&lt;/b&gt; SMALL&lt;br&gt;
					   &lt;b&gt;Appliances:&lt;/b&gt; 2&lt;br&gt;
					   &lt;b&gt;Start Date/Time:&lt;/b&gt; 18/07/11 01:48:00 PM&lt;br&gt;
					</description>
					<pubDate>Mon, 18 Jul 2011 04:19:00 GMT</pubDate>
					<guid>1321959</guid>
				</item>
				
				<item>
					<title>BENDIGO, FINN ST</title>
					<link>http://www.cfa.vic.gov.au/incidents/incident_summary.htm</link>
					<description>
					   &lt;b&gt;District/Region:&lt;/b&gt; REGION 02&lt;br&gt;
					   &lt;b&gt;Location:&lt;/b&gt; BENDIGO&lt;br&gt;
					   &lt;b&gt;Name:&lt;/b&gt; FINN ST&lt;br&gt;
					   &lt;b&gt;Last Updated Date/Time:&lt;/b&gt; 18/07/11 02:15:00 PM&lt;br&gt;
					   &lt;b&gt;Type:&lt;/b&gt; OTHER&lt;br&gt;
					   &lt;b&gt;Status:&lt;/b&gt; SAFE&lt;br&gt;
					   &lt;b&gt;Size:&lt;/b&gt; SMALL&lt;br&gt;
					   &lt;b&gt;Appliances:&lt;/b&gt; 0&lt;br&gt;
					   &lt;b&gt;Start Date/Time:&lt;/b&gt; 18/07/11 02:02:00 PM&lt;br&gt;
					</description>
					<pubDate>Mon, 18 Jul 2011 04:15:00 GMT</pubDate>
					<guid>1321960</guid>
				</item>
				
				<item>
					<title>POINT COOK, MAIN ST</title>
					<link>http://www.cfa.vic.gov.au/incidents/incident_summary.htm</link>
					<description>
					   &lt;b&gt;District/Region:&lt;/b&gt; REGION 14&lt;br&gt;
					   &lt;b&gt;Location:&lt;/b&gt; POINT COOK&lt;br&gt;
					   &lt;b&gt;Name:&lt;/b&gt; MAIN ST&lt;br&gt;
					   &lt;b&gt;Last Updated Date/Time:&lt;/b&gt; 18/07/11 02:12:00 PM&lt;br&gt;
					   &lt;b&gt;Type:&lt;/b&gt; NON STRUCTURE&lt;br&gt;
					   &lt;b&gt;Status:&lt;/b&gt; SAFE&lt;br&gt;
					   &lt;b&gt;Size:&lt;/b&gt; SMALL&lt;br&gt;
					   &lt;b&gt;Appliances:&lt;/b&gt; 0&lt;br&gt;
					   &lt;b&gt;Start Date/Time:&lt;/b&gt; 18/07/11 02:06:00 PM&lt;br&gt;
					</description>
					<pubDate>Mon, 18 Jul 2011 04:12:00 GMT</pubDate>
					<guid>1321961</guid>
				</item>
				
				<item>
					<title>BENDIGO, HARGREAVES ST</title>
					<link>http://www.cfa.vic.gov.au/incidents/incident_summary.htm</link>
					<description>
					   &lt;b&gt;District/Region:&lt;/b&gt; REGION 02&lt;br&gt;
					   &lt;b&gt;Location:&lt;/b&gt; BENDIGO&lt;br&gt;
					   &lt;b&gt;Name:&lt;/b&gt; HARGREAVES ST&lt;br&gt;
					   &lt;b&gt;Last Updated Date/Time:&lt;/b&gt; 18/07/11 01:59:00 PM&lt;br&gt;
					   &lt;b&gt;Type:&lt;/b&gt; STRUCTURE&lt;br&gt;
					   &lt;b&gt;Status:&lt;/b&gt; SAFE&lt;br&gt;
					   &lt;b&gt;Size:&lt;/b&gt; SMALL&lt;br&gt;
					   &lt;b&gt;Appliances:&lt;/b&gt; 0&lt;br&gt;
					   &lt;b&gt;Start Date/Time:&lt;/b&gt; 18/07/11 01:39:00 PM&lt;br&gt;
					</description>
					<pubDate>Mon, 18 Jul 2011 03:59:00 GMT</pubDate>
					<guid>1321958</guid>
				</item>
				
				<item>
					<title>BRIGHT, </title>
					<link>http://www.cfa.vic.gov.au/incidents/incident_summary.htm</link>
					<description>
					   &lt;b&gt;District/Region:&lt;/b&gt; REGION 24&lt;br&gt;
					   &lt;b&gt;Location:&lt;/b&gt; BRIGHT&lt;br&gt;
					   &lt;b&gt;Name:&lt;/b&gt; &lt;br&gt;
					   &lt;b&gt;Last Updated Date/Time:&lt;/b&gt; 18/07/11 01:44:00 PM&lt;br&gt;
					   &lt;b&gt;Type:&lt;/b&gt; STRUCTURE&lt;br&gt;
					   &lt;b&gt;Status:&lt;/b&gt; SAFE&lt;br&gt;
					   &lt;b&gt;Size:&lt;/b&gt; SMALL&lt;br&gt;
					   &lt;b&gt;Appliances:&lt;/b&gt; 0&lt;br&gt;
					   &lt;b&gt;Start Date/Time:&lt;/b&gt; 18/07/11 01:27:00 PM&lt;br&gt;
					</description>
					<pubDate>Mon, 18 Jul 2011 03:44:00 GMT</pubDate>
					<guid>1321957</guid>
				</item>
				
				<item>
					<title>MORWELL, ALEXANDERS RD</title>
					<link>http://www.cfa.vic.gov.au/incidents/incident_summary.htm</link>
					<description>
					   &lt;b&gt;District/Region:&lt;/b&gt; REGION 10&lt;br&gt;
					   &lt;b&gt;Location:&lt;/b&gt; MORWELL&lt;br&gt;
					   &lt;b&gt;Name:&lt;/b&gt; ALEXANDERS RD&lt;br&gt;
					   &lt;b&gt;Last Updated Date/Time:&lt;/b&gt; 18/07/11 01:28:00 PM&lt;br&gt;
					   &lt;b&gt;Type:&lt;/b&gt; NON STRUCTURE&lt;br&gt;
					   &lt;b&gt;Status:&lt;/b&gt; SAFE&lt;br&gt;
					   &lt;b&gt;Size:&lt;/b&gt; SMALL&lt;br&gt;
					   &lt;b&gt;Appliances:&lt;/b&gt; 0&lt;br&gt;
					   &lt;b&gt;Start Date/Time:&lt;/b&gt; 18/07/11 01:10:00 PM&lt;br&gt;
					</description>
					<pubDate>Mon, 18 Jul 2011 03:28:00 GMT</pubDate>
					<guid>1321956</guid>
				</item>
				
				<item>
					<title>FULHAM, MORTIMER DR</title>
					<link>http://www.cfa.vic.gov.au/incidents/incident_summary.htm</link>
					<description>
					   &lt;b&gt;District/Region:&lt;/b&gt; REGION 10&lt;br&gt;
					   &lt;b&gt;Location:&lt;/b&gt; FULHAM&lt;br&gt;
					   &lt;b&gt;Name:&lt;/b&gt; MORTIMER DR&lt;br&gt;
					   &lt;b&gt;Last Updated Date/Time:&lt;/b&gt; 18/07/11 01:00:00 PM&lt;br&gt;
					   &lt;b&gt;Type:&lt;/b&gt; HAZMAT INCIDENT&lt;br&gt;
					   &lt;b&gt;Status:&lt;/b&gt; SAFE&lt;br&gt;
					   &lt;b&gt;Size:&lt;/b&gt; SMALL&lt;br&gt;
					   &lt;b&gt;Appliances:&lt;/b&gt; 0&lt;br&gt;
					   &lt;b&gt;Start Date/Time:&lt;/b&gt; 18/07/11 12:42:00 PM&lt;br&gt;
					</description>
					<pubDate>Mon, 18 Jul 2011 03:00:00 GMT</pubDate>
					<guid>1321954</guid>
				</item>
				
				<item>
					<title>FRANKSTON, SPRAY ST</title>
					<link>http://www.cfa.vic.gov.au/incidents/incident_summary.htm</link>
					<description>
					   &lt;b&gt;District/Region:&lt;/b&gt; REGION 08&lt;br&gt;
					   &lt;b&gt;Location:&lt;/b&gt; FRANKSTON&lt;br&gt;
					   &lt;b&gt;Name:&lt;/b&gt; SPRAY ST&lt;br&gt;
					   &lt;b&gt;Last Updated Date/Time:&lt;/b&gt; 18/07/11 12:57:00 PM&lt;br&gt;
					   &lt;b&gt;Type:&lt;/b&gt; FOREST&lt;br&gt;
					   &lt;b&gt;Status:&lt;/b&gt; SAFE&lt;br&gt;
					   &lt;b&gt;Size:&lt;/b&gt; SMALL&lt;br&gt;
					   &lt;b&gt;Appliances:&lt;/b&gt; 0&lt;br&gt;
					   &lt;b&gt;Start Date/Time:&lt;/b&gt; 18/07/11 12:50:00 PM&lt;br&gt;
					</description>
					<pubDate>Mon, 18 Jul 2011 02:57:00 GMT</pubDate>
					<guid>1321955</guid>
				</item>
			</channel>
		</rss>;
		
		public static const INCIDENT_1_ADDRESS: String = "BARRABOOL RD BELMONT";
		public static const INCIDENT_1_LAT: Number = -37.1;
		public static const INCIDENT_1_LNG: Number = 144.1;
		private static const INCIDENT_1_UPDATED: Date = new Date( 2011, 6, 18, 16, 34, 0 );
		private static const INCIDENT_1_CREATED: Date = new Date( 2011, 6, 18, 16, 34, 0 );
		
		public static const INCIDENT_2_ADDRESS: String = "MAIDEN GULLY";
		public static const INCIDENT_2_LAT: Number = -37.2;
		public static const INCIDENT_2_LNG: Number = 144.2;
		private static const INCIDENT_2_UPDATED: Date = new Date( 2011, 6, 18, 16, 07, 0 );
		private static const INCIDENT_2_CREATED: Date = new Date( 2011, 6, 18, 15, 39, 0 );
		
		public static const INCIDENT_3_ADDRESS: String = "RING RD WENDOUREE";
		public static const INCIDENT_3_LAT: Number = -37.3;
		public static const INCIDENT_3_LNG: Number = 144.3;
		private static const INCIDENT_3_UPDATED: Date = new Date( 2011, 6, 18, 15, 33, 0 );
		private static const INCIDENT_3_CREATED: Date = new Date( 2011, 6, 18, 14, 46, 0 );
		
		public static const INCIDENT_4_ADDRESS: String = "BROWN ST LONG GULLY";
		public static const INCIDENT_4_LAT: Number = -37.4;
		public static const INCIDENT_4_LNG: Number = 144.4;
		private static const INCIDENT_4_UPDATED: Date = new Date( 2011, 6, 18, 15, 30, 0 );
		private static const INCIDENT_4_CREATED: Date = new Date( 2011, 6, 18, 15, 18, 0 );
		
		public static const INCIDENT_5_ADDRESS: String = "BENDIGO";
		public static const INCIDENT_5_LAT: Number = -37.5;
		public static const INCIDENT_5_LNG: Number = 144.5;
		private static const INCIDENT_5_UPDATED: Date = new Date( 2011, 6, 18, 15, 04, 0 );
		private static const INCIDENT_5_CREATED: Date = new Date( 2011, 6, 18, 14, 56, 0 );
		
		public static const INCIDENT_6_ADDRESS: String = "BEECHWORTH-WANGARATTA RD BEECHWORTH";
		public static const INCIDENT_6_LAT: Number = -37.6;
		public static const INCIDENT_6_LNG: Number = 144.6;
		private static const INCIDENT_6_UPDATED: Date = new Date( 2011, 6, 18, 14, 19, 0 );
		private static const INCIDENT_6_CREATED: Date = new Date( 2011, 6, 18, 13, 48, 0 );
		
		public static const INCIDENT_7_ADDRESS: String = "FINN ST BENDIGO";
		public static const INCIDENT_7_LAT: Number = -37.7;
		public static const INCIDENT_7_LNG: Number = 144.7;
		private static const INCIDENT_7_UPDATED: Date = new Date( 2011, 6, 18, 14, 15, 0 );
		private static const INCIDENT_7_CREATED: Date = new Date( 2011, 6, 18, 14, 02, 0 );
		
		public static const INCIDENT_8_ADDRESS: String = "MAIN ST POINT COOK";
		public static const INCIDENT_8_LAT: Number = -37.8;
		public static const INCIDENT_8_LNG: Number = 144.8;
		private static const INCIDENT_8_UPDATED: Date = new Date( 2011, 6, 18, 14, 12, 0 );
		private static const INCIDENT_8_CREATED: Date = new Date( 2011, 6, 18, 14, 06, 0 );
		
		public static const INCIDENT_9_ADDRESS: String = "HARGREAVES ST BENDIGO";
		public static const INCIDENT_9_LAT: Number = -37.9;
		public static const INCIDENT_9_LNG: Number = 144.9;
		private static const INCIDENT_9_UPDATED: Date = new Date( 2011, 6, 18, 13, 59, 0 );
		private static const INCIDENT_9_CREATED: Date = new Date( 2011, 6, 18, 13, 39, 0 );
		
		public static const INCIDENT_10_ADDRESS: String = "BRIGHT";
		public static const INCIDENT_10_LAT: Number = -38.0;
		public static const INCIDENT_10_LNG: Number = 145.0;
		private static const INCIDENT_10_UPDATED: Date = new Date( 2011, 6, 18, 13, 44, 0 );
		private static const INCIDENT_10_CREATED: Date = new Date( 2011, 6, 18, 13, 27, 0 );
		
		public static const INCIDENT_11_ADDRESS: String = "ALEXANDERS RD MORWELL";
		public static const INCIDENT_11_LAT: Number = -38.1;
		public static const INCIDENT_11_LNG: Number = 145.1;
		private static const INCIDENT_11_UPDATED: Date = new Date( 2011, 6, 18, 13, 28, 0 );
		private static const INCIDENT_11_CREATED: Date = new Date( 2011, 6, 18, 13, 10, 0 );
		
		public static const INCIDENT_12_ADDRESS: String = "MORTIMER DR FULHAM";
		public static const INCIDENT_12_LAT: Number = -38.2;
		public static const INCIDENT_12_LNG: Number = 145.2;
		private static const INCIDENT_12_UPDATED: Date = new Date( 2011, 6, 18, 13, 00, 0 );
		private static const INCIDENT_12_CREATED: Date = new Date( 2011, 6, 18, 12, 42, 0 );
		
		public static const INCIDENT_13_ADDRESS: String = "SPRAY ST FRANKSTON";
		public static const INCIDENT_13_LAT: Number = -38.3;
		public static const INCIDENT_13_LNG: Number = 145.3;
		private static const INCIDENT_13_UPDATED: Date = new Date( 2011, 6, 18, 12, 57, 0 );
		private static const INCIDENT_13_CREATED: Date = new Date( 2011, 6, 18, 12, 50, 0 );
		
		private var _cfaIncidentParser: CFAIncidentParser;
		
		[Before]
		public function setUp():void
		{
			_cfaIncidentParser = new CFAIncidentParser(  );
			_cfaIncidentParser.clientGeocoder = new StubbedClientGeocoder(  );
			_cfaIncidentParser.postConstruct(  );
		}
		
		
		[Test(async)]
		public function testCorrectlyParsesData(  ): void
		{
			_cfaIncidentParser.addEventListener( IncidentParserEvent.COMPLETED,
				Async.asyncHandler( this, testCorrectlyParsesDataProcessed, 1000 ) );
			
			_cfaIncidentParser.parseXML( GOOD_DATA );
		}
		
		private function testCorrectlyParsesDataProcessed( event: IncidentParserEvent, ... args ): void
		{
			var incidents: IList = event.incidents;
			
			var incident: IIncident = getIncidentByGuid( incidents, 1321966 );
			assertNotNull( incident );
			
			assertEquals( INCIDENT_1_LAT, incident.location.lat(  ) );
			assertEquals( INCIDENT_1_LNG, incident.location.lng(  ) );
			assertEquals( INCIDENT_1_UPDATED.time, incident.whenCreated.time );
			assertEquals( INCIDENT_1_CREATED.time, incident.whenUpdated.time );
			assertEquals( IncidentTypeEnum.STRUCTURE, incident.type );
			assertEquals( 3, incident.appliances );
			assertEquals( IncidentStatusEnum.GOING, incident.status );
			assertEquals( IncidentSizeEnum.SMALL, incident.size );
			
			
			incident = getIncidentByGuid( incidents, 1321965 );
			assertNotNull( incident );
			
			assertEquals( INCIDENT_2_LAT, incident.location.lat(  ) );
			assertEquals( INCIDENT_2_LNG, incident.location.lng(  ) );
			assertEquals( INCIDENT_2_UPDATED.time, incident.whenUpdated.time );
			assertEquals( INCIDENT_2_CREATED.time, incident.whenCreated.time );
			assertEquals( IncidentTypeEnum.RESCUE, incident.type );
			assertEquals( 0, incident.appliances );
			assertEquals( IncidentStatusEnum.CONTROLLED, incident.status );
			assertEquals( IncidentSizeEnum.SPOT, incident.size );
			
			
			incident = getIncidentByGuid( incidents, 1321962 );
			assertNotNull( incident );
			
			assertEquals( INCIDENT_3_LAT, incident.location.lat(  ) );
			assertEquals( INCIDENT_3_LNG, incident.location.lng(  ) );
			assertEquals( INCIDENT_3_UPDATED.time, incident.whenUpdated.time );
			assertEquals( INCIDENT_3_CREATED.time, incident.whenCreated.time );
			assertEquals( IncidentTypeEnum.WASHAWAY, incident.type );
			assertEquals( 0, incident.appliances );
			assertEquals( IncidentStatusEnum.CONTAINED, incident.status );
			assertEquals( IncidentSizeEnum.MEDIUM, incident.size );
			
			
			incident = getIncidentByGuid( incidents, 1321964 );
			assertNotNull( incident );
			
			assertEquals( INCIDENT_4_LAT, incident.location.lat(  ) );
			assertEquals( INCIDENT_4_LNG, incident.location.lng(  ) );
			assertEquals( INCIDENT_4_UPDATED.time, incident.whenUpdated.time );
			assertEquals( INCIDENT_4_CREATED.time, incident.whenCreated.time );
			assertEquals( IncidentTypeEnum.STRUCTURE, incident.type );
			assertEquals( 0, incident.appliances );
			assertEquals( IncidentStatusEnum.COMPLETED, incident.status );
			assertEquals( IncidentSizeEnum.LARGE, incident.size );
			
			
			incident = getIncidentByGuid( incidents, 1321963 );
			assertNotNull( incident );
			
			assertEquals( INCIDENT_5_LAT, incident.location.lat(  ) );
			assertEquals( INCIDENT_5_LNG, incident.location.lng(  ) );
			assertEquals( INCIDENT_5_UPDATED.time, incident.whenUpdated.time );
			assertEquals( INCIDENT_5_CREATED.time, incident.whenCreated.time );
			assertEquals( IncidentTypeEnum.FALSE_ALARM, incident.type );
			assertEquals( 0, incident.appliances );
			assertEquals( IncidentStatusEnum.SAFE, incident.status );
			assertEquals( IncidentSizeEnum.SMALL, incident.size );
			
			
			incident = getIncidentByGuid( incidents, 1321959 );
			assertNotNull( incident );
			
			assertEquals( INCIDENT_6_LAT, incident.location.lat(  ) );
			assertEquals( INCIDENT_6_LNG, incident.location.lng(  ) );
			assertEquals( INCIDENT_6_UPDATED.time, incident.whenUpdated.time );
			assertEquals( INCIDENT_6_CREATED.time, incident.whenCreated.time );
			assertEquals( IncidentTypeEnum.RESCUE, incident.type );
			assertEquals( 2, incident.appliances );
			assertEquals( IncidentStatusEnum.SAFE, incident.status );
			assertEquals( IncidentSizeEnum.SMALL, incident.size );
			
			
			incident = getIncidentByGuid( incidents, 1321960 );
			assertNotNull( incident );
			
			assertEquals( INCIDENT_7_LAT, incident.location.lat(  ) );
			assertEquals( INCIDENT_7_LNG, incident.location.lng(  ) );
			assertEquals( INCIDENT_7_UPDATED.time, incident.whenUpdated.time );
			assertEquals( INCIDENT_7_CREATED.time, incident.whenCreated.time );
			assertEquals( IncidentTypeEnum.OTHER, incident.type );
			assertEquals( 0, incident.appliances );
			assertEquals( IncidentStatusEnum.SAFE, incident.status );
			assertEquals( IncidentSizeEnum.SMALL, incident.size );
			
			
			incident = getIncidentByGuid( incidents, 1321961 );
			assertNotNull( incident );
			
			assertEquals( INCIDENT_8_LAT, incident.location.lat(  ) );
			assertEquals( INCIDENT_8_LNG, incident.location.lng(  ) );
			assertEquals( INCIDENT_8_UPDATED.time, incident.whenUpdated.time );
			assertEquals( INCIDENT_8_CREATED.time, incident.whenCreated.time );
			assertEquals( IncidentTypeEnum.NON_STRUCTURE, incident.type );
			assertEquals( 0, incident.appliances );
			assertEquals( IncidentStatusEnum.SAFE, incident.status );
			assertEquals( IncidentSizeEnum.SMALL, incident.size );
			
			
			incident = getIncidentByGuid( incidents, 1321958 );
			assertNotNull( incident );
			
			assertEquals( INCIDENT_9_LAT, incident.location.lat(  ) );
			assertEquals( INCIDENT_9_LNG, incident.location.lng(  ) );
			assertEquals( INCIDENT_9_UPDATED.time, incident.whenUpdated.time );
			assertEquals( INCIDENT_9_CREATED.time, incident.whenCreated.time );
			assertEquals( IncidentTypeEnum.STRUCTURE, incident.type );
			assertEquals( 0, incident.appliances );
			assertEquals( IncidentStatusEnum.SAFE, incident.status );
			assertEquals( IncidentSizeEnum.SMALL, incident.size );
			
			
			incident = getIncidentByGuid( incidents, 1321957 );
			assertNotNull( incident );
			
			assertEquals( INCIDENT_10_LAT, incident.location.lat(  ) );
			assertEquals( INCIDENT_10_LNG, incident.location.lng(  ) );
			assertEquals( INCIDENT_10_UPDATED.time, incident.whenUpdated.time );
			assertEquals( INCIDENT_10_CREATED.time, incident.whenCreated.time );
			assertEquals( IncidentTypeEnum.STRUCTURE, incident.type );
			assertEquals( 0, incident.appliances );
			assertEquals( IncidentStatusEnum.SAFE, incident.status );
			assertEquals( IncidentSizeEnum.SMALL, incident.size );
			
			
			incident = getIncidentByGuid( incidents, 1321956 );
			assertNotNull( incident );
			
			assertEquals( INCIDENT_11_LAT, incident.location.lat(  ) );
			assertEquals( INCIDENT_11_LNG, incident.location.lng(  ) );
			assertEquals( INCIDENT_11_UPDATED.time, incident.whenUpdated.time );
			assertEquals( INCIDENT_11_CREATED.time, incident.whenCreated.time );
			assertEquals( IncidentTypeEnum.NON_STRUCTURE, incident.type );
			assertEquals( 0, incident.appliances );
			assertEquals( IncidentStatusEnum.SAFE, incident.status );
			assertEquals( IncidentSizeEnum.SMALL, incident.size );
			
			
			incident = getIncidentByGuid( incidents, 1321954 );
			assertNotNull( incident );
			
			assertEquals( INCIDENT_12_LAT, incident.location.lat(  ) );
			assertEquals( INCIDENT_12_LNG, incident.location.lng(  ) );
			assertEquals( INCIDENT_12_UPDATED.time, incident.whenUpdated.time );
			assertEquals( INCIDENT_12_CREATED.time, incident.whenCreated.time );
			assertEquals( IncidentTypeEnum.HAZMAT_INCIDENT, incident.type );
			assertEquals( 0, incident.appliances );
			assertEquals( IncidentStatusEnum.SAFE, incident.status );
			assertEquals( IncidentSizeEnum.SMALL, incident.size );
			
			
			incident = getIncidentByGuid( incidents, 1321955 );
			assertNotNull( incident );
			
			assertEquals( INCIDENT_13_LAT, incident.location.lat(  ) );
			assertEquals( INCIDENT_13_LNG, incident.location.lng(  ) );
			assertEquals( INCIDENT_13_UPDATED.time, incident.whenUpdated.time );
			assertEquals( INCIDENT_13_CREATED.time, incident.whenCreated.time );
			assertEquals( IncidentTypeEnum.FOREST, incident.type );
			assertEquals( 0, incident.appliances );
			assertEquals( IncidentStatusEnum.SAFE, incident.status );
			assertEquals( IncidentSizeEnum.SMALL, incident.size );
		}
		
		
		/**
		 * Get an incident matching the specified GUID.
		 */
		private function getIncidentByGuid( incidents: IList, guid: uint ): IIncident
		{
			var incidentsIterator: IIterator = incidents.iterator(  );
			
			while ( incidentsIterator.hasNext(  ) )
			{
				var incident: CFAIncident = incidentsIterator.next(  );
				
				if ( incident.rssGuid == guid )
				{
					return incident;
				}
			}
			
			return null;
		}
	}
}


import com.google.maps.LatLng;
import com.google.maps.LatLngBounds;
import com.google.maps.interfaces.IClientGeocoder;
import com.google.maps.services.ClientGeocoderOptions;
import com.google.maps.services.GeocodingEvent;
import com.google.maps.services.GeocodingResponse;
import com.google.maps.services.Placemark;
import com.misoneism.fire.service.CFAIncidentParserTest;

import flash.events.EventDispatcher;

import org.as3commons.collections.Map;
import org.as3commons.collections.framework.IMap;

class StubbedClientGeocoder extends EventDispatcher implements IClientGeocoder
{
	private static const BASE_GEOCODING_LOCATION: String = " victoria australia";
	
	private var geocodingMap: IMap /* of String -> LatLng */;
	
	public function StubbedClientGeocoder(  )
	{
		geocodingMap = new Map(  );
		
		geocodingMap.add( CFAIncidentParserTest.INCIDENT_1_ADDRESS + BASE_GEOCODING_LOCATION,
			new LatLng( CFAIncidentParserTest.INCIDENT_1_LAT, CFAIncidentParserTest.INCIDENT_1_LNG ) );
		geocodingMap.add( CFAIncidentParserTest.INCIDENT_2_ADDRESS + BASE_GEOCODING_LOCATION,
			new LatLng( CFAIncidentParserTest.INCIDENT_2_LAT, CFAIncidentParserTest.INCIDENT_2_LNG ) );
		geocodingMap.add( CFAIncidentParserTest.INCIDENT_3_ADDRESS + BASE_GEOCODING_LOCATION,
			new LatLng( CFAIncidentParserTest.INCIDENT_3_LAT, CFAIncidentParserTest.INCIDENT_3_LNG ) );
		geocodingMap.add( CFAIncidentParserTest.INCIDENT_4_ADDRESS + BASE_GEOCODING_LOCATION,
			new LatLng( CFAIncidentParserTest.INCIDENT_4_LAT, CFAIncidentParserTest.INCIDENT_4_LNG ) );
		geocodingMap.add( CFAIncidentParserTest.INCIDENT_5_ADDRESS + BASE_GEOCODING_LOCATION,
			new LatLng( CFAIncidentParserTest.INCIDENT_5_LAT, CFAIncidentParserTest.INCIDENT_5_LNG ) );
		geocodingMap.add( CFAIncidentParserTest.INCIDENT_6_ADDRESS + BASE_GEOCODING_LOCATION,
			new LatLng( CFAIncidentParserTest.INCIDENT_6_LAT, CFAIncidentParserTest.INCIDENT_6_LNG ) );
		geocodingMap.add( CFAIncidentParserTest.INCIDENT_7_ADDRESS + BASE_GEOCODING_LOCATION,
			new LatLng( CFAIncidentParserTest.INCIDENT_7_LAT, CFAIncidentParserTest.INCIDENT_7_LNG ) );
		geocodingMap.add( CFAIncidentParserTest.INCIDENT_8_ADDRESS + BASE_GEOCODING_LOCATION,
			new LatLng( CFAIncidentParserTest.INCIDENT_8_LAT, CFAIncidentParserTest.INCIDENT_8_LNG ) );
		geocodingMap.add( CFAIncidentParserTest.INCIDENT_9_ADDRESS + BASE_GEOCODING_LOCATION,
			new LatLng( CFAIncidentParserTest.INCIDENT_9_LAT, CFAIncidentParserTest.INCIDENT_9_LNG ) );
		geocodingMap.add( CFAIncidentParserTest.INCIDENT_10_ADDRESS + BASE_GEOCODING_LOCATION,
			new LatLng( CFAIncidentParserTest.INCIDENT_10_LAT, CFAIncidentParserTest.INCIDENT_10_LNG ) );
		geocodingMap.add( CFAIncidentParserTest.INCIDENT_11_ADDRESS + BASE_GEOCODING_LOCATION,
			new LatLng( CFAIncidentParserTest.INCIDENT_11_LAT, CFAIncidentParserTest.INCIDENT_11_LNG ) );
		geocodingMap.add( CFAIncidentParserTest.INCIDENT_12_ADDRESS + BASE_GEOCODING_LOCATION,
			new LatLng( CFAIncidentParserTest.INCIDENT_12_LAT, CFAIncidentParserTest.INCIDENT_12_LNG ) );
		geocodingMap.add( CFAIncidentParserTest.INCIDENT_13_ADDRESS + BASE_GEOCODING_LOCATION,
			new LatLng( CFAIncidentParserTest.INCIDENT_13_LAT, CFAIncidentParserTest.INCIDENT_13_LNG ) );
	}
	
	public function getViewport():LatLngBounds
	{
		return null;
	}
	
	public function resetCache():void
	{
	}
	
	public function geocode(arg0:String):void
	{
		if ( geocodingMap.hasKey( arg0 ) )
		{
			respondWithLocation( geocodingMap.itemFor( arg0 ) );
		}
		else
		{
			trace( "Could not find '" + arg0 + "'." );
		}
	}
	
	private function respondWithLocation( latLng: LatLng ): void
	{
		var placemark:Placemark = new Placemark();
		placemark.point = latLng;
		
		var geocodingResponse: GeocodingResponse = new GeocodingResponse();
		geocodingResponse.placemarks = [placemark];
		
		var event: GeocodingEvent = new GeocodingEvent( GeocodingEvent.GEOCODING_SUCCESS );
		event.response = geocodingResponse;
		
		dispatchEvent( event );
	}
	
	public function reverseGeocode(arg0:LatLng):void
	{
	}
	
	public function setOptions(arg0:ClientGeocoderOptions):void
	{
	}
	
	public function getOptions():ClientGeocoderOptions
	{
		return null;
	}
	
	public function setBaseCountryCode(arg0:String):void
	{
	}
	
	public function getBaseCountryCode():String
	{
		return null;
	}
	
	public function setViewport(arg0:LatLngBounds):void
	{
	}
	
	public function getBaseEventDispatcher():Object
	{
		return null;
	}
	
	public function get interfaceChain():Array
	{
		return null;
	}
	
	public function get wrapper():Object
	{
		return null;
	}
	
	public function set wrapper(arg0:Object):void
	{
	}
}